$(document).ready(function() {
	$("#menu").find("#contact").addClass("selected dropdown");
	$('#name, #subject, #email,#message').focus(function(){
		$(this).css({"border-color":"#d5d5d5","background":"-webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF))","background":"-moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px)"});
	});
	$("#buttonsend").click(function(){
		// $(this).attr("disable",true);
		if(checkName() && checkEmail() && checkPhone()){
			$("#submit_span").attr("style","display: block;");
			$("#buttonsend").attr("disabled", "disabled");
			$("#contactform").submit();
		}
	});
});
function checkName(){
	var name = $("#name").val();
	if(null == name || "" == name){
		$("#err_span").html("姓名必须填写！");
		return false;
	}else{
		return true;
	}
}
function checkEmail(){
	var email = $("#email").val();
	var regex = /^(?:\w+\.?)*\w+@(?:\w+\.)*\w+$/;
	if(null != email && "" != email){
		if(regex.test(email)){
			return true;
		}else{
			$("#err_span").html("邮箱格式不正确！");
			return false;
		}
	}else{
		return true;
	}
}

function checkPhone(){
	var phone = $("#phone").val();
	if(phone == null || "" == phone){
		$("#err_span").html("联系方式为空！");
		return false;
	}
	var regex=/(^(\d{2,4}[-_－— ]?)?\d{3,8}([-_－— ]?\d{3,8})?([-_－— ]?\d{1,7})?$)|(^0?1[35]\d{9}$)/;
	if(regex.test(phone)){
		return true;
	}else{
		$("#err_span").html("联系方式不正确！");
		return false;
	}
}
